package com.view
{
	import caurina.transitions.Tweener;
	
	import com.util.EcholenTransform;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.*;
	
	import sekati.display.CoreSprite;
	import sekati.draw.Rect;
		
	
	public class awardItem extends CoreSprite
	{
		protected var fadeSpeed : Number = .25;
		protected var tweenType : String = "easeOutQuint";		
		protected var rect:Rect;
		protected var awardpic: Sprite = new Sprite();
		
		protected var testss:int=0;;
		
		/** this clash is define the award box in first stage*/
		public function awardItem() 
		{
			super(); 
			drawBg();			
			addEventListener(MouseEvent.MOUSE_OVER, _onOver);
			addEventListener(MouseEvent.MOUSE_OUT, _onOut);
			addEventListener(MouseEvent.CLICK,_onPress);
		}
		/** this function is draw the rect box which contain's the main awards */
		private function drawBg():void{
			/*
			bggrey = new Sprite();
			bggrey.graphics.beginFill(0x101010,1);			
			bggrey.graphics.drawRect(0,0,320,250);
			bggrey.graphics.endFill();
			bggrey.blendMode=BlendMode.MULTIPLY;
			addChild(bggrey);
			
			bggreylay = new Sprite();
			bggreylay.graphics.beginFill(0x000000,1);			
			bggreylay.graphics.drawRect(10,10,300,230);
			bggreylay.graphics.endFill();
			addChild(bggreylay);*/
			rect = new Rect(320, 260, -160,-125, 1, 0x101010);
			//rect.alpha=0.3;
			addChild(rect);
		}
		public function setAwardPic(bd:Bitmap):void{
			awardpic.addChild(bd);
			addChild(awardpic);
			awardpic.x=-150;
			awardpic.y=-115;
		}		
		
		/** event_handler:: this headel the MouseOver event */
		private function _onOver(e : MouseEvent = null) : void {
			//Tweener.addTween(this,{alpha: 0.8, time: fadeSpeed, transition: tweenType} )			
			//glowadd();

		}
		
		/** event_hander:: this handel the MouseOut event */
		private function _onOut(e : MouseEvent = null) : void {						
			//glowtweenmuil();					
			//Tweener.addTween(this,{alpha: 0.3, time: fadeSpeed, transition: tweenType} );		
		}
		
		/** event_hander:: this handel the Clicker event */
		private function _onPress(e:Event):void{
			var et:EcholenTransform=new EcholenTransform();
			var BitmapFilter:DisplacementMapFilter=et.getBitmapFilter(this);							
			this.filters=[BitmapFilter];
		}
		
		protected function clearfilter():void{
			this.filters =[];
		}
				

		protected function glowadd():void{
			var glow:GlowFilter=new GlowFilter();
			glow.alpha=0.8;			
			glow.color=0xe0d6b0;
			glow.blurX=10;
			glow.blurY=10;
			glow.strength=2;
			glow.quality=BitmapFilterQuality.MEDIUM;	
			this.filters=[glow];
			glowtweenadd();		
		}
		protected function glowtweenadd():void{
			Tweener.removeAllTweens();
			Tweener.addTween(this,{_Glow_blurX:20,_Glow_blurY:20,_Glow_alpha:0.8,time: fadeSpeed*4,transition: tweenType,onComplete:glowtweenremove});			
		}
		protected function glowtweenremove():void{
			Tweener.removeAllTweens();
			Tweener.addTween(this,{_Glow_blurX:10,_Glow_blurY:10,_Glow_alpha:0.3,time: fadeSpeed*4,transition: tweenType,onComplete:glowtweenadd});
		}
		protected function glowtweenmuil():void{
			Tweener.removeAllTweens();
			Tweener.addTween(this,{_Glow_blurX:0,_Glow_blurY:0,_Glow_alpha:0,time: fadeSpeed*4,transition: tweenType,onComplete:clearfilter});
		}
				
		protected function shawdowadd():void{
			var shawdow:DropShadowFilter=new DropShadowFilter();
			shawdow.alpha=0.8;
			shawdow.angle=0;
			shawdow.color=0x000000;
			shawdow.blurX=10;
			shawdow.blurY=10;
			shawdow.distance=0;
			shawdow.quality=BitmapFilterQuality.MEDIUM;	
			this.filters=[shawdow];
			shawdowtweenadd();		
		}		
		protected function shawdowtweenadd():void{
			Tweener.addTween(this,{_DropShadow_blurX:20,_DropShadow_blurY:20,time: fadeSpeed*4,transition: tweenType,onComplete:shawdowtweenremove});			
		}
		protected function shawdowtweenremove():void{
			Tweener.addTween(this,{_DropShadow_blurX:10,_DropShadow_blurY:10,time: fadeSpeed*4,transition: tweenType,onComplete:shawdowtweenadd});
		}
		protected function shawdowtweenmuil():void{
			Tweener.addTween(this,{_DropShadow_blurX:0,_DropShadow_blurY:0,time: fadeSpeed*4,transition: tweenType,onComplete:clearfilter});
		}
		
		protected function bluradd():void{
			var blur:BlurFilter = new BlurFilter();
			blur.blurX = 0;
			blur.blurY = 0;
			blur.quality = BitmapFilterQuality.MEDIUM;		
			this.filters=[blur];
			Tweener.addTween(this,{_Blur_blurX:10,_Blur_blurY:10,time: fadeSpeed,transition: tweenType});
		}
		

	}
}